import Rsa from '../src/Rsa'
// 从对象获取公钥和私钥
// const rsa = new Rsa()
// const keys = rsa.getKeys()
// console.log(keys)
// const res_en_by_pub = rsa.encryptByPubKey('hello')
// const res_de_by_pri = rsa.decryptByPriKey(res_en_by_pub)
// const res_sign_by_pri = rsa.signature('123456')
// const res_verify_by_pub = rsa.verify('123456', res_sign_by_pri)
// console.log('公钥加密：' + res_en_by_pub)
// console.log('私钥解密：' + res_de_by_pri)
// console.log('私钥签名：' + res_sign_by_pri)
// console.log('公钥验证：' + res_verify_by_pub)
// 从已有文件加载私钥和公钥
const rsa = new Rsa()
const pubKey = Rsa.getKey(process.cwd() + '\\' + 'rsa_pub')
const priKey = Rsa.getKey(process.cwd() + '\\' + 'rsa_pri')
const res_en_by_pub = rsa.encryptByPubKey('123456', pubKey)
const res_de_by_pri = rsa.decryptByPriKey(res_en_by_pub, priKey)
const res_sign_by_pri = rsa.signature('123456', priKey)
const res_verify_by_pub = rsa.verify('123456', res_sign_by_pri, pubKey)
console.log('公钥加密：' + res_en_by_pub)
console.log('私钥解密：' + res_de_by_pri)
console.log('私钥签名：' + res_sign_by_pri)
console.log('公钥验证：' + res_verify_by_pub)